import request from '@/utils/request'
import { TradeMarkResponseData, TradeMark } from './type'
// 品牌管理模块接口地址
enum API {
  TRADEMARK_URL = '/admin/product/baseTrademark/',
  TradeMark_ADD_URL = '/admin/product/baseTrademark/save',
  UPDARE_TRADEMARK_URL = '/admin/product/baseTrademark/update',
  GET_TRADEMARK_URL = '/admin/product/baseTrademark/get/ ',
  DELETE_TRADEMARK_URL = '/admin/product/baseTrademark/remove/ ',
}

// 获取品牌列表
export const reqGetTrademarkList = (page: number, limit: number) =>
  request.get<any, TradeMarkResponseData>(
    API.TRADEMARK_URL + `${page}/${limit}`,
  )

// 添加或者更新品牌
export const reqAddUpdateTrademark = (data: TradeMark) => {
  // 判断id是否存在
  if (data.id) {
    // 更新品牌
    return request.put(API.UPDARE_TRADEMARK_URL, data)
  } else {
    // 新增品牌
    return request.post(API.TradeMark_ADD_URL, data)
  }
}

// 获取信息
export const reqGetTrademarkInfo = (id: number) =>
  request.get<TradeMark>(API.GET_TRADEMARK_URL + id)

// 删除品牌
export const reqDeleteTrademark = (id: number) =>
  request.delete(API.DELETE_TRADEMARK_URL + id)
